<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<%@ include file="../include/vueComponent.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>项目信息收集</title>
</head>
<link rel="stylesheet" href="${ctx}/resources/vue-element-lib/detail.css">
<body>
<div id="app">
    <div class="layui-tab layui-tab-brief" lay-filter="xqxx-tab-all">
        <ul class="layui-tab-title">
            <li id="tbglId" class="layui-this" lay-id="0">项目信息收集详情</li>
            <li id="zgysId" lay-id="1">历史审批信息</li>
        </ul>
        <div class="layui-tab-right">
            <c:if test="${isAuditFlag eq '1'}">
                <template v-if="layId==0">
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" @click="save(1)">提交
                    </button>
                    <button type="button" class="layui-btn layui-btn-radius" @click="save(2)">发起预立项</button>
                </template>
            </c:if>
            <c:if test="${auditTabFlag eq '1'}">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" @click="audit(0)">不同意
                </button>
                <button type="button" class="layui-btn layui-btn-radius" @click="audit(1)">同意</button>
            </c:if>
        </div>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show">
                <div class="container">
                    <el-form ref="formRef" label-width="140px" label-suffix="："
                             label-position="left">
                        <%--项目基础信息--%>
                        <div class="title">
                            <h3>项目基础信息</h3>
                        </div>
                        <!--表单-->
                        <el-row>
                            <x-col>
                                <el-form-item label="项目编码">
                                    <span>{{info.proCode}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="所属公司">
                                    <span>{{info.compName}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="项目名称" :rules="[{ required: true}]">
                                    <x-input v-model="info.proName" name="项目名称"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="营销经理">
                                    <span>{{info.staffName}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="项目地点" :rules="[{ required: true}]">
                                    <el-select v-model="info.refProvinceId" style="width: 200px" filterable
                                               placeholder="请选择"
                                               @change="selProvince">
                                        <el-option v-for="item in province" :key="item.id" :label="item.sname"
                                                   :value="item.id"></el-option>
                                    </el-select>

                                    <el-select v-model="info.refCityId" style="width: 200px;margin-left: 10px" filterable
                                               placeholder="请选择"
                                               @change="selCity">
                                        <el-option v-for="item in city" :key="item.id" :label="item.sname"
                                                   :value="item.id"></el-option>
                                    </el-select>
                                    <el-select v-model="info.refAreaId" style="width: 200px;margin-left: 10px" filterable
                                               placeholder="请选择"
                                               @change="selArea">
                                        <el-option v-for="item in area" :key="item.id" :label="item.sname"
                                                   :value="item.id"></el-option>
                                    </el-select>
                                    <el-input v-model="info.proAddress" style="margin-left: 10px" placeholder="请输入内容"
                                              style="width: calc(100% - 312px)"></el-input>
                                </el-form-item>
                            </x-col>

                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="项目类型" :rules="[{ required: true}]">
                                    <x-select v-model="info.proTypes" :options="projectType"
                                              name="项目类型"></x-select>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="入库情况" :rules="[{ required: true}]">
                                    <x-select v-model="info.isInStore" :options="storageSituation"
                                              name="入库情况"></x-select>
                                </el-form-item>
                            </x-col>

                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="项目业态" :rules="[{ required: true}]">
                                    <x-select v-model="info.proFormat" :options="proFormaType"
                                              name="项目业态"></x-select>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="项目渠道" position="right" :rules="[{ required: true}]">
                                    <x-select v-model="info.fromChannel" :options="projectChannel"
                                              name="项目渠道"></x-select>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="业主单位名称" :rules="[{ required: true}]">
                                    <div style="display: flex;justify-content: flex-start;align-items: center">
                                        <el-select v-model="info.unitId" style="width: 100%" filterable
                                                   placeholder="请选择业主单位">
                                            <el-option v-for="item in owner" :key="item.id" :label="item.coopName"
                                                       :value="item.id"></el-option>
                                        </el-select>
                                        <shiro:hasPermission name="SAVE_COOPINFO">
                                            <button type="button" class="layui-btn layuiadmin-btn-admin1"
                                                    style="margin-left: 10px" data-type="add">
                                                <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新增
                                            </button>
                                        </shiro:hasPermission>
                                    </div>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="单位性质" :rules="[{ required: true}]">
                                    <x-input v-model="info.coopProperty" name="单位性质"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="内部关系" :rules="[{ required: true}]">
                                    <x-input v-model="info.innerRelationship" name="内部关系"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="总投资额(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.sumAmount" name="总投资额" type="number"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                                             min="0"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="建设周期(年)" :rules="[{ required: true}]">
                                    <x-input v-model="info.buildYears" name="建设周期" type="number"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                                             min="0"></x-input>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="运营周期(年)" :rules="[{ required: true}]">
                                    <x-input v-model="info.omYears" name="运营周期" type="number" min="0"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                                    />
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="合作周期(年)" :rules="[{ required: true}]">
                                    <x-input v-model="info.workYears" name="合作周期" type="number"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                                             min="0"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="项目简介" :rules="[{ required: true}]">
                                    <x-input v-model="info.proRemarks" name="项目简介" type="textarea"
                                             :rows="4"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <%--项目合作方--%>
                        <div class="title">
                            <h3>项目合作方</h3>
                        </div>
                        <div class="unit">
                            <div class="unit_add">
                                <button class="layui-btn layuiadmin-btn-admin" type="button" data-type="add"
                                        @click="addSummary">
                                    <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加合作单位
                                </button>
                            </div>
                            <div class="unit_center">
                                <div class="unit_img">
                                    <div class="item" v-for="(item,index) in summary" :key="index"
                                         v-if="summary.length>1">
                                        <img src="${ctx}/resources/images/del.png" alt="" @click="delSummary(index)">
                                    </div>
                                </div>
                                <el-table :data="summary" style="width: 100%" border>
                                    <el-table-column prop="unit" label="合作单位" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.sgCoopId" filterable placeholder="请选择"
                                                       style="width: 100%">
                                                <el-option v-for="item in coopInfoList" :key="item.id"
                                                           :label="item.coopName" :value="item.id"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="effect" label="单位作用" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.coopEffect" filterable placeholder="请选择">
                                                <el-option v-for="item in coopEffect" :key="item.code"
                                                           :label="item.name" :value="item.code"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="type" label="合作类型" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.cooperationType" filterable placeholder="请选择">
                                                <el-option v-for="item in cooperationType" :key="item.code"
                                                           :label="item.name" :value="item.code"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </div>
                        <div class="title">
                            <h3>项目投资构成</h3>
                        </div>
                        <div class="investment">
                            <div class="investment_add">
                                <button class="layui-btn layuiadmin-btn-admin" type="button"
                                        @click.stop="addInvestment">
                                    <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加子项
                                </button>
                            </div>
                            <div class="investment_top_del" v-if="itemName.length>1">
                                <div class="item"></div>
                                <div class="item" v-for="(item,index) in itemName" :key="index">
                                    <img src="${ctx}/resources/images/del.png" alt="" @click="delInvestmentTop(index)">
                                </div>
                            </div>
                            <div class="investment_center">
                                <div class="investment_img">
                                    <div class="item" v-for="(item,index) in investmentInfoVos" :key="index">
                                        <img src="${ctx}/resources/images/del.png" alt=""
                                             @click="delInvestmentLeft(index)"
                                             v-if="item.isAdd">
                                    </div>
                                </div>
                                <el-table :data="investmentInfoVos" style="width: 100%" border ref="multipleTable">
                                    <el-table-column prop="name" label="名称" align="center">
                                        <template slot-scope="scope">
                                            <div v-if="scope.$index<=2||scope.row.name=='合计(万元)'">{{scope.row.name}}
                                            </div>
                                            <div v-else>
                                                <%--                                hover--%>
                                                <el-popover placement="bottom" width="50" trigger="hover"
                                                            style="opacity: 0">
                                                    <div class="el-popover_item">
                                                        <el-button type="button">添加费用</el-button>
                                                    </div>
                                                    <div class="el-popover_item">
                                                        <el-button type="button" @click="addInvestmentList(scope.row)">
                                                            添加子项
                                                        </el-button>
                                                    </div>
                                                    <div slot="reference">
                                                        <div style="cursor: pointer" v-if="!scope.row.isAdd">
                                                            {{scope.row.name}}
                                                        </div>
                                                        <el-input v-else v-model="scope.row.name" type="number" min="0"
                                                                  placeholder="请输入费用名称"></el-input>
                                                    </div>
                                                </el-popover>
                                            </div>
                                        </template>
                                    </el-table-column>
                                    <el-table-column align="center" v-for="(item,index) in itemName "
                                                     :key="index">
                                        <template #header>
                                            <el-input v-model="item.name" :value="item.name"
                                                      placeholder="请输入子项费用名称"></el-input>
                                        </template>
                                        <template slot-scope="scope">
                                            <template v-if="scope.row.name=='合计(万元)'">
                                                <el-input v-model="scope.row.list[index]" type="number" min="0"
                                                          :disabled="true"
                                                          style="color: #000"></el-input>
                                            </template>

                                            <template v-else>
                                                <el-input v-model="scope.row.list[index]" type="number" min="0"
                                                          oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                                                          placeholder="请输入" @input="investmentTotal"></el-input>
                                            </template>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="type" label="合计" align="center" type="index" width="100">
                                        <template slot-scope="scope">
                                            <div v-if="scope.$index<=2"></div>
                                            <div v-else>{{scope.row.total?scope.row.total:'0'}}</div>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </div>
                        <%--回报机制--%>
                        <div class="repay">
                            <div class="title">
                                <h3>回报机制</h3>
                            </div>
                            <el-row>
                                <x-col position="full">
                                    <el-form-item label="" prop="b1">
                                        <el-radio-group v-model="info.backMech">
                                            <el-radio label="1">政府付费</el-radio>
                                            <el-radio label="2">可行性缺口补助</el-radio>
                                            <el-radio label="3">使用者付费</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </x-col>
                            </el-row>
                            <el-row>
                                <el-col :span="6" :offset="2" class="mr-10">
                                    <el-form-item label="工程费用下浮率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.downRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="合理利润率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.profitRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="投资回报率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.investBackRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="6" :offset="2" class="mr-10">
                                    <el-form-item label="折现率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.discountRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="建设期融资利率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.finRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="融资回报率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.finBackRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="6" :offset="2" class="mr-10">
                                    <el-form-item label="资本金回报率(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.capitalBackRate"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <%--                                <el-col :span="6" class="mr-10">--%>
                                <%--                                    <el-form-item label="总投资额" >--%>
                                <%--                                        <x-input size="small" type="number" min="0" v-model="info.sumAmount"/>--%>
                                <%--                                    </el-form-item>--%>
                                <%--                                </el-col>--%>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="资本金比例(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.capitalPercent"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="资本金数额(万元)">
                                        <x-input size="small" type="number" min="0" v-model="info.capitalFund"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="6" :offset="2" class="mr-10">
                                    <el-form-item label="我方股权出资金额(万元)">
                                        <x-input size="small" type="number" min="0" v-model="info.stockFund"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" class="mr-10">
                                    <el-form-item label="我方股权比例(%)">
                                        <x-input size="small" type="number" min="0" v-model="info.stockPercent"
                                                 oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </div>
                        <div class="title">
                            <h3>项目风险</h3>
                        </div>
                        <div class="unit">
                            <div class="unit_add">
                                <button class="layui-btn layuiadmin-btn-admin" type="button" data-type="add"
                                        @click="addRisk">
                                    <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加风险点
                                </button>
                            </div>
                            <div class="unit_center">
                                <div class="unit_img">
                                    <div class="item" v-for="(item,index) in riskTable" :key="index"
                                         v-if="riskTable.length>1">
                                        <img src="${ctx}/resources/images/del.png" alt="" @click="delRisk(index)">
                                    </div>
                                </div>
                                <el-table :data="riskTable" style="width: 100%" border>
                                    <el-table-column prop="unit" label="风险描述" align="center">
                                        <template slot-scope="scope">
                                            <el-input v-model="scope.row.riskDesc" placeholder="请输入风险点"></el-input>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="effect" label="风险等级" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.riskLevel" placeholder="请选择">
                                                <el-option v-for="item in riskLevel" :key="item.code" :label="item.name"
                                                           :value="item.code"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="type" label="处理策略" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.solveWay" placeholder="请选择">
                                                <el-option v-for="item in riskSolveWay" :key="item.code"
                                                           :label="item.name" :value="item.code"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="type" label="最新进展" align="center">
                                        <template slot-scope="scope">
                                            <el-input v-model="scope.row.latestProgress"
                                                      placeholder="请描述风险进展"></el-input>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </div>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="项目优点">
                                    <x-input v-model="info.proMerit" type="textarea" :rows="4"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="其他说明">
                                    <x-input v-model="info.proOthers" type="textarea" :rows="4"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <template v-if="standardTable&&standardTable.length>0">
                            <div class="title">
                                <h3>底线标准情况</h3>
                            </div>
                            <div class="unit">
                                <div class="unit_center">
                                    <el-table :data="standardTable" style="width: 100%" border>
                                        <el-table-column prop="standardName" label="标准名称"
                                                         align="center"></el-table-column>
                                        <el-table-column prop="standardCode" label="标准值"
                                                         align="center"></el-table-column>
                                        <el-table-column prop="nowProgress" label="当前进度"
                                                         align="center"></el-table-column>
                                        <el-table-column prop="resultMsg" label="结论" align="center"></el-table-column>
                                    </el-table>
                                </div>
                            </div>
                        </template>
                        <div class="title">
                            <h3>项目附件信息</h3>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">项目可研报告</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="1-upload-more">上传</button>
                                    <div class="layui-upload-list" id="1-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">两评一案</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="2-upload-more">上传</button>
                                    <div class="layui-upload-list" id="2-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">其他资料</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="3-upload-more">上传</button>
                                    <div class="layui-upload-list" id="3-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <c:if test="${auditTabFlag eq '1'}">
                            <div class="title">
                                <h3>审批信息</h3>
                            </div>
                            <%@ include file="process/process-audit.jsp" %>
                        </c:if>
                    </el-form>
                </div>
            </div>
            <div class="layui-tab-item">
                <%@ include file="process/process-history.jsp" %>
            </div>
            <!-- 新建合作单位窗口 -->
            <form>
                <div class="layui-form" lay-filter="add_form" id="add_form"
                     style="padding: 20px 30px 0 0; display: none">
                    <fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo">
                        <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">基础信息></legend>
                        <div class="layui-form-item" style="height:10px;"></div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">单位全称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="coopName" maxlength="50" style="width:300px;"
                                           lay-verify="required|COC"
                                           placeholder="请输入合作单位名称" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">所在城市</label>
                                <div class="layui-input-inline">
                                    <select name="provinceCode" id="query-select-provinceCode"
                                            lay-filter="query-select-provinceCode" lay-verify="required"
                                            lay-search>
                                        <option value="">请选择</option>
                                        <c:if test="${not empty provinces }">
                                            <c:forEach items="${provinces}" var="pvn">
                                                <option value="${pvn.id }">${pvn.sname }</option>
                                            </c:forEach>
                                        </c:if>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <select name="cityCode" id="query-select-cityCode"
                                            lay-filter="query-select-cityCode" lay-verify="required"
                                            lay-search>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <select name="areaCode" id="query-select-areaCode"
                                            lay-search>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">单位类别</label>
                                <div class="layui-input-inline">
                                    <infopub:select entireName="-单位类别" id="query-form-coopType"
                                                    name="types" type="dic" groupNo="A00010059">
                                    </infopub:select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">成立年份</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="upYear" maxlength="50"
                                           lay-verify="required|yearNumber"
                                           placeholder="请输入成立年份"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">注册资金（万元）</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="regCapital" maxlength="50"
                                           lay-verify="required|doubleNumber"
                                           placeholder="请输入注册资金" onblur="isNumberAndFloat1(this);arabiaToCN(this,2);"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">法人</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="legalPerson" maxlength="50"
                                           lay-verify="required|CHS"
                                           placeholder="请输入法人姓名" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">经营范围</label>
                            <div class="layui-input-block">
						<textarea name="bizScope" class="layui-textarea" maxlength="1000"
                                  lay-verify="required" style="width: 595px; height: 90px;"></textarea>
                            </div>
                        </div>
                    </fieldset>
                    <fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo">
                        <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">详细信息></legend>
                        <div class="layui-form-item" style="height:10px;"></div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">代表工程（选填）</label>
                            <div class="layui-input-block">
						<textarea name="representWorks" class="layui-textarea"
                                  maxlength="100" style="width: 595px; height: 90px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">简介及评价（选填）</label>
                            <div class="layui-input-block">
						<textarea name="synopsis" class="layui-textarea" maxlength="100"
                                  style="width: 595px; height: 90px;"></textarea>
                            </div>
                        </div>
                    </fieldset>
                    <fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo">
                        <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">联系人信息></legend>
                        <div class="layui-form-item" style="height:10px;"></div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">联系人</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="linkMan" maxlength="50"
                                           placeholder="请输入联系人名"
                                           autocomplete="off" lay-verify="required|CHS" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">联系人电话</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="linkPhone" maxlength="50"
                                           lay-verify="required|telNumber"
                                           placeholder="请输入联系人电话"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    <div class="layui-form-item layui-hide">
                        <input type="button" lay-submit lay-filter="add_form_submit"
                               id="add_form_submit" value="确认保存">
                    </div>
                </div>

            </form>

        </div>
    </div>
</div>
<script src="${ctx}/resources/vue-element-lib/jquery.js"></script>
<script>
    let fileArr = [];
    var staticPath = '${fileHttpPre}';
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'upload', 'table', 'transfer', 'laydate', 'element', 'layer'], function () {
        var $ = layui.$
            , upload = layui.upload
            , table = layui.table
            , form = layui.form
            , element = layui.element
            , layer = layui.layer;

        //选项卡切换监听
        element.on('tab(xqxx-tab-all)', function (data) {
            var layId = $(this).attr('lay-id');
            vm.$data.layId = layId
            if (layId === "0") {
            } else if (layId === "1") {
                loadTable(layId);
            } else if (layId === "2") {
            }
        });


        /****  新增合作单位信息 ***/
            // 按钮事件
        var active = {
                add: function () {
                    clean_form("add_form");//清空表单
                    layer.open({
                        type: 1
                        , title: '合作单位信息'
                        , content: $('#add_form')
                        , area: layui.admin.screen() < 2 ? ['80%', '550px'] : ['850px', '550px']
                        , btn: ['确定', '取消']
                        , btnAlign: 'c'
                        , yes: function (index, layero) {
                            var submitID = 'add_form_submit'
                                , submit = layero.contents().find('#' + submitID);

                            //监听提交
                            form.on('submit(' + submitID + ')', function (data) {
                                var field = data.field; //获取提交的字段
                                //提交 Ajax 成功后，静态更新表格中的数据
                                $.ajax({
                                    type: 'post',
                                    url: basePath + '/coopinfo/addCoop',
                                    data: field,
                                    success: function (result) {
                                        if (result.success) {
                                            // table.reload('LAY-coopinfo-manage'); //数据刷新
                                            clean_form("add_form");//清空表单
                                            layer.close(index); //关闭弹层
                                            vm.queryCoopInfo()
                                            vm.$data.info.unitId = result.entity.id
                                            /* //额外处理select
                                            $("#add_from-compId").val('');
                                            form.render("select"); */
                                        } else {
                                            layer.msg(result.msg, {icon: 7});
                                        }
                                    }
                                });
                            });
                            submit.trigger('click');
                        }
                    });
                }
            }
        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin1').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        // 新增-合作单位省份select监听
        form.on('select(query-select-provinceCode)', function (data) {
            var provinceCode = data.value;
            $('#query-select-cityCode').html('');
            $('#query-select-areaCode').html('');
            getCityByProvinceId($('#query-select-cityCode'), provinceCode);
        });

        //新增-合作单位城市select监听
        form.on('select(query-select-cityCode)', function (data) {
            var cityCode = data.value;
            $('#query-select-areaCode').html('');
            getAreaByCityId($('#query-select-areaCode'), cityCode)
        });

        /**校验合作单位名是否存在（新增时使用）*/
        function getCityByProvinceId(obj, provinceCode, cityId) {
            var $ = layui.$
                , form = layui.form
            //获取省份下的所有城市
            $.ajax({
                type: "POST", //提交方式
                url: "${ctx}/coopinfo/getCityByPro",//路径
                data: {
                    "provinceCode": provinceCode
                },//数据，这里使用的是Json格式进行传输
                success: function (result) {//返回数据根据结果进行相应的处理
                    if (result.flag == true) {
                        var strBuffer = "";
                        strBuffer += '<option value="">请选择</option>';
                        layui.$.each(result.citys, function (i, item) {
                            if (item.id != null && item.sname != null) {
                                strBuffer += '<option value=' + item.id;
                                if (cityId != undefined && cityId == item.id) {
                                    strBuffer += ' selected';
                                }
                                strBuffer += '>' + item.sname + '</option>';
                            }
                        });
                        obj.append(strBuffer);
                        form.render();
                    } else {
                        layer.msg('数据通信异常~', {icon: 0});
                    }
                }
            });
        }

        function getAreaByCityId(obj, cityCode, areaId) {
            var $ = layui.$
                , form = layui.form
            //获取城市下的区县
            $.ajax({
                type: "POST", //提交方式
                url: "${ctx}/coopinfo/getAreaByCity",//路径
                data: {
                    "cityCode": cityCode
                },//数据，这里使用的是Json格式进行传输
                success: function (result) {//返回数据根据结果进行相应的处理
                    if (result.flag == true) {
                        var strBuffer = "";
                        strBuffer += '<option value="">请选择</option>';
                        layui.$.each(result.areas, function (i, item) {
                            strBuffer += '<option value=' + item.id;
                            if (areaId != undefined && areaId == item.id) {
                                strBuffer += ' selected';
                            }
                            strBuffer += '>' + item.sname + '</option>';
                        });
                        obj.append(strBuffer);
                        form.render();
                    } else {
                        layer.msg('数据通信异常~', {icon: 0});
                    }
                }
            });
        }

        /******** 合作单位信息****************/

        function loadTable(layId) {
            // 表单
            table.render({
                elem: '#lay-lsspxx-create-manage'
                , url: basePath + '/historyProcess/list?proCode=${proCode}'
                , cols: [[
                    {
                        field: 'startTime', title: '发起时间', width: 145, width: 155, templet: function (d) {
                            return layui.util.toDateString(d.startTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    , {field: 'startRealName', title: '发起人', width: 145}
                    , {field: 'proFlowType', title: '审批阶段', width: 145}
                    , {field: 'proFlowNode', title: '审批节点', width: 145}
                    , {
                        field: 'dealTime', title: '审批日期', width: 155, templet: function (d) {
                            return layui.util.toDateString(d.dealTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    , {field: 'dealName', title: '审批人', width: 160}
                    , {
                        field: 'state', title: '审批状态'
                    }
                    , {
                        title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                            var optStr = "";
                            optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>查看</a>';
                            return optStr;
                        }
                    }
                ]]
                , page: true
                , limit: 10
            });

            // 监听操作列
            table.on('tool(lay-lsspxx-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看
                    parent.layui.index.openTabsPage(basePath + '/historyProcess/toDetail?processId=' + data.processId, '历史流程信息 > 详情');
                }
            });
        }

        ;(function () {
            //定义构造函数
            var Upfile = function (ele, type, opt) {
                this.defaults = {
                    //elem:‘#uploadPic‘	//绑定元素
                    elem: $(ele)	//绑定元素
                    , url: basePath + '/contractInfo/uploadAtt/',
                    data: {
                        types: type
                    },
                    multiple: true,
                    accept: 'file',
                    acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',

                    method: 'post',
                    before: function (obj) { //obj参数包含的信息
                        layer.load(); //上传loading
                    },
                    done: function (res) {
                        //如果上传失败
                        if (res.code > 0) {
                            layer.closeAll('loading'); //关闭loading
                            return layer.msg(res.msg, {icon: 7});
                        }
                        //上传完毕
                        if (res.entity != null && res.entity.length > 0) {
                            fileArr.push(res.entity[0])
                            for (var i in res.entity) {
                                var contractInfo = res.entity[i];
                                var arr = contractInfo.split("|");
                                var imgSrc = "";
                                var suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                                if (suffix == 'jpg' || suffix == 'png') {
                                    imgSrc = "${fileHttpPre}/" + arr[3];
                                } else {
                                    imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                                }
                                $('#' + type + '-upload-more-list')
                                    .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                        + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                        + arr[3] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                        + arr[2] + '\')";>删除</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                        + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                            }
                        }
                    },
                    allDone: function (obj) { //当文件全部被提交后，才触发
                        layer.closeAll('loading'); //关闭loading
                    },
                    error: function () {
                        layer.closeAll('loading'); //关闭loading
                        //上传失败
                        layer.msg("上传失败，请稍后再试~", {icon: 7});
                    }
                }
                this.options = $.extend({}, this.defaults, opt);
            };

            //定义方法
            Upfile.prototype = {
                init: function () {
                    var _this = this;
                    return layui.use('upload', function () {
                        var upload = layui.upload;

                        //执行实例
                        var uploadInst = upload.render(_this.options);
                    });
                }
            };

            //在插件中使用对象
            $.fn.upfile = function (options) {
                var upfile = new Upfile(this, options);
                return upfile.init();
            }
        })();
        //上传文件
        $('#1-upload-more').upfile(1);
        $('#2-upload-more').upfile(2);
        $('#3-upload-more').upfile(3);
    });

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
        fileArr.map((el, idx) => {
            if (el.split('|')[2] == index) {
                fileArr.splice(idx, 1)
            }
        })
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url, '', 'left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

    /*核心*/
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                layId: '0',
                procNodeList: [],
                tempNodeList: [],
                auditMsg: '',//审批意见
                id: '',
                options: [],
                info: {
                    proName: '',//项目名称
                    proTypes: '',//项目类型
                    isInStore: '',//入库情况
                    proFormat: '',//项目业态
                    omYears: '',//运营周期
                    refProvinceId: '',//省 id
                    refCityId: '',//市 id
                    refAreaId: '',//区id
                    proAddress: '',//详细地址
                    innerRelationship: '',//内部关系
                    coopProperty: '',//单位性质
                    unitId: '',//业主单位Id
                    fromChannel: '',//项目渠道
                    workYears: '',//合作周期
                    buildYears: '',//建设周期
                    sumAmount: '',//总投资额
                    proRemarks: '',//项目简介
                    //回报机制
                    downRate: '',//工程费用下浮率
                    profitRate: '',//合理利润率
                    investBackRate: '',//投资回报率
                    discountRate: '',//折现率
                    finRate: '',//建设期融资利率
                    finBackRate: '',//融资回报率
                    capitalBackRate: '',//资本金回报率
                    capitalPercent: '',//资本金比例
                    capitalFund: '',//资本金数额
                    stockFund: '',//我方股权出资金额
                    stockPercent: '',//我方股权比例
                    //项目风险
                    proMerit: '',//项目优点
                    proOthers: '',//其他说明
                    isTrack: '',//是否继续追踪
                    applyOpinion: '',//审批意见


                    backMech: '',
                },
                coopInfoList: [],//合作单位
                coopEffect: [],//单位作用
                cooperationType: [],//合作类型
                proFormaType: [],//项目业态
                projectChannel: [],//项目渠道
                projectType: [],//项目类型
                riskLevel: [],//风险等级
                storageSituation: [],//入库情况
                province: [],//省
                city: [],//市
                area: [],//区
                summary: [],//合作单位 sgCoopId 合作单位ID---coopEffect 单位作用 --- setCooperationType --合作类型

                riskSolveWay: [],//处理策略
                //项目类型
                projectType: [],
                //入库情况
                storageSituation: [],

                // 是否追踪
                traceOptions: [
                    {name: '继续跟踪', code: 0},
                    {name: '停止跟踪', code: 1}
                ],
                summary: [], // sgCoopId 合作单位ID---coopEffect 单位作用 --- setCooperationType --合作类型

                itemName: [],
                investmentInfoVos: [
                    {name: '合作周期(年)', list: [''], total: 0,},
                    {name: '建设周期(年)', list: [''], total: 0,},
                    {name: '运营周期(年)', list: [''], total: 0,},
                    {name: '1.建安工程费用(万元)', list: [''], total: 0,},
                    {name: '2.设备购置费用(万元)', list: [''], total: 0,},
                    {name: '3.工程建设其他(万元)', list: [''], total: 0,},
                    {name: '3.1征地拆迁费(万元)', list: [''], total: 0,},
                    {name: '4.预备费(万元)', list: [''], total: 0,},
                    {name: '5.建设期利息(万元)', list: [''], total: 0,},
                    {name: '合计(万元)', list: [0], total: 0,}],
                owner: [],      //业主单位
                //项目风险点
                riskTable: [],//riskDesc:风险描述 riskLevel:等级 solveWay:处理策略 latestProgress:最新进展
                //底线标准情况
                standardTable: [],//name:标准名称 value:标准值 schedule:当前进度  conclusion:结论
                isCity: false,
            }
        },
        created() {
            console.log(${showFlag})
            let that = this;
            this.getDrop();//获取下拉
            this.getAddress()//获取地址
            this.queryCoopInfo();//获取业主单位
            that.id = "${id}";
            that.processId = "${processId}";
            if (that.id && that.id != 'undefined') {
                that.queryCollectDetail();
                that.queryProcessList();
            } else {
                that.itemName = [{name: '子项名称1'}]
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/getCollectDomain',  //请求数据接口
                    data: {},
                    success: function (result) {
                        if (result.entity) {
                            that.info.compName = result.entity.compName;
                            that.info.proCode = result.entity.proCode;
                            that.info.staffName = result.entity.staffName;
                        }
                    }
                });
            }
        },
        mounted() {

        },
        methods: {
            // 查看详情
            queryCollectDetail() {
                let that = this;
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/queryCollectDetail',  //请求数据接口
                    data: {
                        id: that.id
                    },
                    success: function (result) {
                        loading.close();
                        if (result.success) {
                            that.info = result.entity.projectInfo;
                            that.info = numToStr(that.info);
                            that.info.isTrack = Number(that.info.isTrack);
                            that.getAddress(that.info.refProvinceId, 1)//获取地址
                            that.getAddress(that.info.refCityId, 2)//获取地址
                            that.riskTable = result.entity.riskTable;
                            that.summary = result.entity.summaryCoops;
                            let arr = [];
                            that.summary.map((el, index) => {
                                if (el.coopEffect == -1) {
                                    arr = that.summary.splice(index, 1)
                                }
                            })
                            that.info.unitId = arr && arr.length > 0 ? arr[0].sgCoopId : '';
                            that.showFile(result.entity.fileAtt);
                            if (result.entity.investmentInfoVos && result.entity.investmentInfoVos.length > 0) {
                                that.itemName = result.entity.itemName;
                                that.investmentInfoVos = result.entity.investmentInfoVos;
                            } else {
                                that.itemName = [{name: '子项名称1'}]
                            }
                            if (result.entity.standardTable.length > 0) {
                                that.standardTable = result.entity.standardTable;
                            }
                        }
                    }
                });
            },
            queryCoopInfo() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/proSell/queryCoopInfo',  //请求数据接口
                    data: {},
                    success: function (result) {
                        that.owner = result;
                    }
                });
            },
            checkCity() {
                console.log(this.info.refProvinceId)
                let that = this;
                let id = (that.info.refProvinceId ? that.info.refProvinceId + ',' : '') + (that.info.refCityId ? that.info.refCityId + ',' : '') + (that.info.refAreaId ? that.info.refAreaId + ',' : '')
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/checkCity',  //请求数据接口
                    data: {
                        address: id
                    },
                    success: function (result) {
                        if (result.code == 400) {
                            that.$message.error(result.msg);
                            that.isCity = true;
                        } else {
                            that.isCity = false;
                        }
                    }
                });
            },
            showFile(fileList) {
                if (fileList && fileList.length > 0) {
                    fileArr = fileList;
                    for (let i in fileList) {
                        let contractInfo = fileList[i];
                        let arr = contractInfo.split("|");
                        let imgSrc = "";
                        let suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                        if (suffix == 'jpg' || suffix == 'png') {
                            imgSrc = "${fileHttpPre}/" + arr[3];
                        } else {
                            imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                        }
                        $('#' + arr[0] + '-upload-more-list')
                            .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                + arr[3] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                + arr[2] + '\')";>删除</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                    }
                }
            },

            error(text) {
                this.$message({
                    message: text,
                    type: 'warning'
                });
            },
            //获取下拉
            getDrop() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/getDrop',  //请求数据接口
                    data: {},
                    success: function (result) {
                        that.coopInfoList = result.entity.coopInfoList;//合作单位
                        that.coopEffect = result.entity.coopEffect;//单位作用
                        that.cooperationType = result.entity.cooperationType;//合作类型
                        that.proFormaType = result.entity.proFormaType;//项目业态
                        that.projectChannel = result.entity.projectChannel;//项目渠道
                        that.projectType = result.entity.projectType;//项目类型
                        that.riskLevel = result.entity.riskLevel;//风险等级
                        that.riskSolveWay = result.entity.riskSolveWay;//风险等级
                        that.storageSituation = result.entity.storageSituation;//入库情况

                    }
                });
            },
            //获取地址
            getAddress(id, type = 0) {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/getAddress',  //请求数据接口
                    data: {
                        id: (id ? id + ',' : '') + (type ? type : '0')
                    },
                    success: function (result) {
                        if (type == 0) {
                            that.province = result.entity;//省
                        } else if (type == 1) {
                            that.city = result.entity//市
                        } else {
                            that.area = result.entity//区
                            if (that.area.length < 2) {
                                that.checkCity();
                            }
                        }
                    }
                });
            },
            selProvince(id) {
                this.city = [];
                this.area = [];
                this.info.refCityId = '';//市 id
                this.info.refAreaId = '';//区id
                this.info.proAddress = '';//详细地址
                this.getAddress(id, 1)//获取地址
            },
            selCity(id) {
                this.area = [];
                this.info.refAreaId = '';//区id
                this.info.proAddress = '';//详细地址
                this.getAddress(id, 2)//获取地址
            },
            selArea() {
                console.log(1111);
                if (this.info.refAreaId) {
                    this.checkCity();
                }
            },
            //添加合作单位
            addSummary() {
                let obj = {
                    sgCoopId: '',
                    coopEffect: '',
                    cooperationType: ''
                }
                this.summary.push(obj);
            },
            delSummary(index) {
                this.summary.splice(index, 1)
            },
            //删除子项
            delInvestmentTop(index) {
                this.itemName.splice(index, 1);
                this.investmentInfoVos.map(el => {
                    el.list.splice(index, 1);
                })
                this.investmentTotal();
            },
            delInvestmentLeft(index) {
                this.investmentInfoVos.splice(index, 1);
                this.investmentTotal();
            },
            addInvestment() {
                if (this.itemName.length < 6) {
                    this.itemName.push({name: ''});
                    this.investmentInfoVos.map(el => {
                        el.list.push('');
                    })
                }
            },
            //合计 计算数字
            investmentTotal() {
                //计算每一列的相加
                let arr1 = [];
                this.investmentInfoVos.map((el, idx) => {
                    if (el.name != '合计(万元)' && idx > 2) {
                        el.list.map((el1, index) => {
                            if (arr1[index] == undefined) {
                                arr1[index] = 0
                                arr1[index] = Number(arr1[index]) + Number(el1);
                            } else {
                                arr1[index] = Number(arr1[index]) + Number(el1);
                                arr1[index] = Number(arr1[index]).toFixed(2)

                            }
                        })
                    }
                    if (el.name == '合计(万元)') {
                        el.list = arr1
                    }
                })
                let sum = 0;
                // 计算每一行的总和
                this.investmentInfoVos.map((el, idx) => {
                    let num = 0;
                    el.list.map(el1 => {
                        num += Number(el1) ? Number(el1) : 0;
                    })
                    el.total = num ? Number(num).toFixed(2) : 0;
                    if (el.name != '合计(万元)' && idx > 2) {
                        sum += Number(el.total);
                    } else {
                        el.total = Number(sum).toFixed(2);
                        console.log(sum)
                    }
                })
            },
            addInvestmentList(e) {
                for (let x in this.investmentInfoVos) {
                    if (this.investmentInfoVos[x].name == e.name) {
                        let obj = {
                            name: '',
                            list: [],
                            total: 0,
                            isAdd: true,
                        }

                        this.itemName.map(el => {
                            let num = ''
                            obj.list.push(num)
                        })
                        this.investmentInfoVos.splice(Number(x) + 1, 0, obj)
                    }
                }
            },
            //添加风险点
            addRisk() {
                let obj = {description: '', grade: '', strategy: '', progress: ''};
                this.riskTable.push(obj);
            },
            //删除风险点
            delRisk(index) {
                this.riskTable.splice(index, 1)
            },
            //保存
            save(type) {
                let that = this;
                if (that.isCity) return that.error('城市调研信息不存在该城市,请重新选择城市!');
                if (that.info.proName == '') return that.error('请选择项目名称');
                if (that.info.refProvinceId == '') return that.error('请选择省');
                if (that.info.refCityId == '') return that.error('请选择市');
                if (that.info.proAddress == '') return that.error('请输入详细地址');
                if (that.info.proTypes == '') return that.error('请选择项目类型');
                if (that.info.isInStore == '') return that.error('请选择入库情况');
                if (that.info.proFormat == '') return that.error('请选择项目业态');
                if (that.info.omYears == '') return that.error('请输入运营周期');
                if (that.info.fromChannel == '') return that.error('请选择项目渠道');
                if (that.info.coopProperty == '') return that.error('请选择单位性质');
                if (that.info.innerRelationship == '') return that.error('请输入内部关系');
                if (that.info.workYears == '') return that.error('请输入合作周期');
                if (that.info.buildYears == '') return that.error('请输入建设周期');
                if (that.info.sumAmount == '') return that.error('请输入总投资额');
                if (that.info.proRemarks == '') return that.error('请输入项目简介');
                // if (that.info.backMech == '') return that.error('请选择回报机制');
                // if (that.info.downRate == '') return that.error('请输入工程费用下浮率');
                // if (that.info.profitRate == '') return that.error('请输入合理利润率');
                // if (that.info.investBackRate == '') return that.error('请输入投资回报率');
                // if (that.info.discountRate == '') return that.error('请输入折现率');
                // if (that.info.finRate == '') return that.error('请输入建设期融资利率');
                // if (that.info.finBackRate == '') return that.error('请输入融资回报率');
                // if (that.info.capitalBackRate == '') return that.error('请输入资本金回报率');
                // if (that.info.capitalPercent == '') return that.error('请输入资本金比例');
                // if (that.info.capitalFund == '') return that.error('请输入资本金数额');
                // if (that.info.stockFund == '') return that.error('请输入我方股权出资金额');
                // if (that.info.stockPercent == '') return that.error('请输入我方股权比例');
                if (that.investmentInfoVos && that.investmentInfoVos.length > 0) {
                    let total = that.investmentInfoVos[that.investmentInfoVos.length - 1].total;
                    if (Number(that.info.sumAmount) != Number(total)) return that.error('项目投资构成与总投资额不一致，请重新输入！');
                }
                if (that.info.proMerit == '') return that.error('请输入项目优点');
                if (that.info.proOthers == '') return that.error('请输入其他说明');
                let obj = {
                    'id': that.id || null,
                    "summary": that.summary,  //合作方信息
                    "projectInfo": that.info,//项目基础信息
                    "itemName": that.itemName,//项目子项信息
                    "investmentInfoVos": that.investmentInfoVos,//投资构成信息
                    "projectRisk": that.riskTable,//项目风险信息
                    "fileAtt": fileArr,//附件信息
                }
                //上传所有addTime 为空
                if (obj.projectInfo.addTime) {
                    obj.projectInfo.addTime = null;
                    obj.projectInfo.uptTime = null;
                }
                obj.summary.map(el => {
                    if (el.addTime) {
                        el.addTime = null;
                        el.uptTime = null;
                    }
                })
                obj.projectRisk.map(el => {
                    if (el.addTime) {
                        el.addTime = null;
                        el.uptTime = null;
                    }
                })
                let str = JSON.stringify(obj).replace(/\"/g, '\\"')
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/save',  //请求数据接口
                    async: false,
                    data: {
                        bodyStr: str,
                        submitType: type
                    },
                    success: function (result) {
                        if (result.entity) {
                            if (result.entity.success) {
                                that.$message({
                                    message: '提交成功',
                                    type: 'success'
                                });
                                setTimeout(function () {
                                    // 刷新首页
                                    let index = window.parent.layui.admin.tabsPage.index
                                    if (index == null) {
                                        window.close();
                                    } else {
                                        var iframe = window.parent.layui.admin.tabsBody((index - 1)).find(".layadmin-iframe");
                                        iframe[0].contentWindow.location.reload();
                                        top.layui.admin.closeThisTabs(); // 关闭当前标签页
                                    }
                                }, 3000);
                            } else {
                                that.$message.error(result.entity.msg);
                            }
                        } else {
                            if (result.success) {
                                that.$message({
                                    message: '提交成功',
                                    type: 'success'
                                });
                            } else {
                                that.$message.error(result.msg);
                            }
                        }
                    }
                });
            },
            queryProcessList() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/historyProcess/processList',  //请求数据接口
                    data: {processId: that.processId},
                    success: function (result) {
                        if (result.entity) {
                            that.procNodeList = result.entity.procNodeList;
                            that.tempNodeList = result.entity.tempNodeList;
                        }
                    }
                });
            },
            audit(status) {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/auditProcess',  //请求数据接口
                    async: false,
                    data: {
                        id: that.id,
                        processId: that.processId,
                        status: status,
                        auditMsg: that.auditMsg,
                        isTrack: that.info.isTrack,
                    },
                    success: function (result) {
                        if (result.success) {
                            that.$message({
                                message: '操作成功',
                                type: 'success'
                            });
                            setTimeout(function () {
                                // 刷新首页
                                let index = window.parent.layui.admin.tabsPage.index
                                if (index == null) {
                                    window.close();
                                } else {
                                    var iframe = window.parent.layui.admin.tabsBody((index - 1)).find(".layadmin-iframe");
                                    iframe[0].contentWindow.location.reload();
                                    top.layui.admin.closeThisTabs(); // 关闭当前标签页
                                }
                            }, 3000);
                        } else {
                            that.$message.error('保存失败');
                        }
                    }
                });
            }
        }
    })
</script>
</body>
</html>

